﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Threading . Tasks;
using System . Collections . ObjectModel;
using System . Xml . Linq;

namespace WenceyWang . RichMan4L . Maps
{
	/// <summary>
	/// 代表地图上的道路
	/// </summary>
	public abstract class Road : Block
	{
		public long Id { get; set; }

		public virtual void Stay ( Players . Player player )
		{

		}

		public bool BlockMoving { get { return Buffs . Any ( ( buff ) => buff . BlockMoving ); } }

		public List<Buffs . RoadBuff> Buffs { get; private set; } = new List<RichMan4L . Buffs . RoadBuff> ( );

		public override MapSize Size { get { return MapSize . Small; } set { throw new InvalidOperationException ( ); } }

		public override int PondingDecrease { get { return 400; } }

		/// <summary>
		/// 获取路径的末端和末端之前的路径
		/// </summary>
		/// <param name="previous">前一个路径</param>
		/// <param name="moveCount">能延长的路径长度</param>
		/// <returns>路径</returns>
		public abstract Path Route ( Road previous , int moveCount , Path result = null );

		public abstract bool CanEnter ( Road road );

		public override void UpdateView ( )
		{

		}

		public override void StartDay ( Calendars . GameDate nextDate )
		{

		}

		protected override void Dispose ( bool disposing )
		{
			if ( !disposedValue )
			{
				if ( disposing )
				{
					foreach ( var item in Buffs )
					{
						item . Dispose ( );
					}
				}
			}
			base . Dispose ( disposing );
		}


		public override void EndToday ( )
		{
			throw new NotImplementedException ( );
		}
		public Road ( XElement resource ) : base ( resource )
		{
			Id = Convert . ToInt64 ( resource . Attribute ( nameof ( Id ) ) . Value );
		}

	}
}
